<script setup lang="ts">
  import { AppType } from '@/types/index';
  import store from '@/store/index';
  import { useStorage, STORAGE_KEY } from '@/hooks/storage.hoos';
  import { useConnectGoEasy } from './hooks/go-easy.hooks';
  import { CurrentUser } from '@/types/storage/current-user.storage.type';

  const App: AppType = {
    onLaunch() {
      // const name = 'name';
      console.log(store.state);

      const [currentUser] = useStorage<CurrentUser>(STORAGE_KEY.CURRENT_USER);
      // 如果已登陆，尝试连接
      if (currentUser.value) {
        const { value: user } = currentUser;
        useConnectGoEasy({
          id: user.uuid,
          data: {
            name: user.name,
            avatar: user.avatar
          }
        });
      }
    },
    onShow() {
      console.log('App Show');
    },
    onHide() {
      console.log('App Hide');
    }
  };
  export default App;
</script>

<style lang="scss">
  /* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
  @import 'uview-ui/index.scss';
  /* 每个页面公共css */
  @import url('./static/style/chatInterface.css');
</style>
